<!DOCTYPE html>
<html>
<head>

        <meta charset="utf-8" />

        <title>Demo Chat</title>

        <link href="bootstrap.css" rel="stylesheet">

	<style>
		body {
			padding:20px;
		}
		#console {
			height: 400px;
			overflow: auto;
		}
		.username-msg {color:orange;}
		.connect-msg {color:green;}
		.disconnect-msg {color:red;}
		.send-msg {color:#888}
	</style>


	<script src="js/socket.io/socket.io.js"></script>
        <script src="js/moment.min.js"></script>
        <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

	<script>
        var ws = new WebSocket("ws:192.168.1.20:8000/socket");

        ws.onopen = function(){
            console.log("open open open !!!");
            // ws.send("Test!");

        };

        ws.onmessage = function(evt){console.log(evt.data);};

        ws.onclose = function(evt){
            console.log("WebSocketClosed!");};

        ws.onerror = function(evt){console.log("WebSocketError!");};

        function sendDisconnect() {
            socket.disconnect();
              }

		function sendMessage() {
            var message = $('#msg').val();
            ws.send(message);
		}

		function sendMessage1() {
            var message = $('#msg').val();
            ws.send(message);
        }

		function output(message) {
            var currentTime = "<span class='time'>" +  moment().format('HH:mm:ss.SSS') + "</span>";
            var element = $("<div>" + currentTime + " " + message + "</div>");
           $('#console').prepend(element);
    }

        $(document).keydown(function(e){
            if(e.keyCode == 13) {
                $('#send').click();
                $('#send1').click();
            }

        });
	</script>
</head>

<body>

	<h1>Netty-socketio Demo Chat</h1>

	<br/>

	<div id="console" class="well">
	</div>

        <form class="well form-inline" onsubmit="return false;">
           <input id="msg" class="input-xlarge" type="text" placeholder="Type something..."/>
           <button type="button" onClick="sendMessage()" class="btn" id="send">Send</button>
           <button type="button" onClick="sendMessage1()" class="btn" id="send1">Send1</button>
           <button type="button" onClick="sendDisconnect()" class="btn">Disconnect</button>
        </form>



</body>

</html>
